Enable jest cacheDirectory configuration #3860
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2687 .
Enables the user to override Jest's
cacheDirectory
configuration, mainly to make it easier for users to speed up their builds on CI, by caching jest's cache in between builds.How I tested
"jest": { "cacheDirectory": "tmp/jest-cache" }
to/packages/react-scripts/package.json
yarn test
cacheDirectory
tmp/jest-cache
is created in/packages/react-scripts/template/
yarn create-react-app a-test-app
Documentation
I've added
cacheDirectory
to the list of supported overrides in the template README.md. I've also addedresetMocks
,resetModules
andwatchPathIgnorePattern
as they weirdly wasn't on the list, even though the are supported. If they are omitted on purpose, I'm sorry, I'll remove them again.I've also added a short section about using the
cacheDirectory
option to speed up tests on CI.Future work
Should this be accepted, I'll gladly looking into speeding up this repos tests using the
cacheDirectory
pattern. However I'm inexperienced with TravisCI so I might come up short. Please let me know in the comments if I should pursue this or not.